package com.xiaotu.threadMethod;

/**
 * @Author xiaotu
 * @Description //TODO
 * @Date 2022/3/25 16:19
 * @ClassName TestYeild
 * @Version 1.0
 * 线程礼让
 * 礼让未必成功,看cpu心情
 **/
public class TestYeild implements Runnable{
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+"开始执行");
        Thread.yield();
        System.out.println(Thread.currentThread().getName()+"结束执行");
    }
    public static void main(String[] args) {
        TestYeild testYeild = new TestYeild();
        new Thread(testYeild,"mua! (*╯3╰)").start();
        new Thread(testYeild,"礼让@#$%^&*()").start();
    }
}
